#include <bits/stdc++.h>
using namespace std;
int n, l, r;
int main() {
	freopen("candy.in", "r", stdin);
	freopen("candy.out", "w", stdout);
	cin >> n >> l >> r;
	int x = l % n, y = r % n;
	if(r - l > 2 * n) cout << n - 1;
	else {
		if(x > y) cout << n - 1;
		else if(x == y) {
			if(l == r) cout << x;
			else cout << n - 1;
		} 
		else {
			if(r - l < n) cout << y;
			else cout << n - 1;
		} 
	} 
	return 0;
} 
